home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 1 / Macwelt DVD 1.toast / Web-Publishing / HTML-Editoren / Alpha ƒ / Mode Examples / FORTRAN-Example.f < prev    next >
Encoding:
Text File  |  2000-10-30  |  16.0 KB  |  529 lines

  1.  
  2. c FORTRAN Example.f
  3. c Included in the Alpha distribution as an example of the Fort mode
  4. c source of original document:
  5. c http://www.fortran.com/
  6.  
  7.        PROGRAM COLORIT
  8.  
  9. c    *****************************************
  10. c    By Dale Bickel, Senior Electronics Engineer, dbickel@fcc.gov
  11. c    Audio Services Div., FCC (USA)
  12. c    http://www.fcc.gov/mmb/asd/
  13. c    
  14. c    This Fortran CGI application may be copied and/or 
  15. c    modified freely.  No restrictions are placed on its use. 
  16. c    ******************************************
  17. c    This program was created to develop a Fortran CGI.  It 
  18. c    receives input from HTML and generates HTML output.
  19. c    It could easily be modified to allow input from the 
  20. c    keyboard or a Fortran routine.
  21.  
  22. c    CGI access is required if the program is used as written. 
  23. c    The programming has not been optimized.  
  24. c    ****************************************** 
  25.  
  26. c    This Fortran 77 program prints the HTML color corresponding 
  27. c    to a six-place hexadecimal number.  It also prints, in table form,
  28. c    the colors which result by increasing or decreasing a single
  29. c    digit from the entered number.
  30. c    *******************************************
  31.  
  32. c    First, we read the six digit value sent over from the HTML.
  33. c    Because this program uses the GET method, this program
  34. c    reads the environment variable QUERY_STRING.   We 
  35. c    read each character from the string, and ignore unnecessary
  36. c    characters (here, ... ?input=  ).
  37. c    ********************************************
  38.  
  39. c    QS represents the character string  QUERY_STRING
  40. c    Digit is the numerical value of the corresponding character
  41. c    12 places are required to cover the whole QUERY_STRING
  42. c    input=AAAAAA
  43. c    ********************************************
  44.  
  45. c    Fortran reminders:
  46. c    Column 1 -- enter C for Comments
  47. c    Column 2-5 -- statement labels
  48. c    Column 6 -- continuation character
  49. c    Column 7 -- start commands in this column
  50. c    Column 72 -- Last column of statement -- use continuation
  51. c        characters or another Format statement if command is longer
  52.  
  53. c    First Statement of Program :  **********************             
  54.  
  55.        Character*12 QS
  56.        Character*1 newcolor
  57.        Dimension digit(12) 
  58.  
  59. c    ********************************************
  60.  
  61. c    Retrieve environment variable QUERY_STRING, using
  62. c    "getenv" get environment variable subroutine on system.
  63. c    This command may differ on other computer systems.
  64. c    QUERY_STRING will be stored in the character string QS.
  65.  
  66.        call getenv('QUERY_STRING', QS)
  67.     
  68. c    ******************************************
  69. c    Now we set up the Fortran code to generate HTML output.
  70. c    The Content-type: text/html // statement accomplishes
  71. c    this action.  The slashes // are VERY IMPORTANT!! 
  72. c    Watch the placement of the quotes!
  73.  
  74.        Write(6,55)
  75.  55    Format("Content-Type: text/html"//)
  76.  
  77. c    ******************************************
  78. c    From now on, the usual HTML tags will appear inside
  79. c    FORMAT statements.  Watch the quotation marks!
  80. c    Note that HTML tags may be placed on the same line, or 
  81. c    one tag may be broken up onto different lines.
  82.  
  83.        Write(6,64)
  84.        Write(6,65)
  85.        Write(6,66)
  86.  
  87.  64    Format('<HTML><HEAD><Title>')
  88.  65    Format('COLORIT Color Generator --- A Fortran CGI</Title>')
  89.  66    Format('</Head><Body bgcolor=' '#FFFFFF' '>')
  90.  
  91. c    Note the placement of the quote marks for the HTML 
  92. c    code bgcolor="#FFFFFF"> in the previous statement
  93. c    ******************************************
  94.  
  95. c    Here we generate the HTML for the output document's
  96. c    heading:
  97.  
  98.        Write(6,1400)
  99.        Write(6,1401)
  100.        Write(6,1402)
  101.        Write(6,1403)
  102.        Write(6,1404)
  103.        Write(6,1405)
  104.        Write(6,1406)     
  105.        Write(6,1407)
  106.        Write(6,1408)
  107.        Write(6,1410)
  108.        Write(6,1411)
  109.        Write(6,1412)
  110.        Write(6,1413)
  111.        Write(6,1414)
  112.        Write(6,1415)
  113.        Write(6,1416)
  114.        Write(6,1417)
  115.        Write(6,1418)
  116.  
  117.  1400  FORMAT('<Center>')      
  118.  1401  FORMAT('<A HREF=' 'http://www.fcc.gov/' '><IMG SRC=' )
  119.  1402  FORMAT('http://www.fcc.gov/fcc-gifs/hpban1.gif ' 'ALT=' )
  120.  1403  FORMAT(' [ Federal Communications Commission ] ' '></A>')
  121.  1404  FORMAT('<BR><a href=' )
  122.  1405  FORMAT('http://www.fcc.gov/fcc-bin/htimage/pub/www/pub/opa.map')
  123.  1406  FORMAT('><img src=' 'http://www.fcc.gov/fcc-gifs/iconbar.gif' )
  124.  1407  FORMAT('height=20' 'width=525' 'alt=' '[icon bar]' 'vspace=5' )
  125.  1408  FORMAT('border=1' 'ismap></a></CENTER><P>' )
  126.  1410  FORMAT('<Center><TABLE Border=0 ><TR ALIGN=LEFT>')
  127.  1411  FORMAT('<TD align=' 'left' '><IMG SRC=' )
  128.  1412  FORMAT('http://www.fcc.gov/fcc-gifs/sealtiny.gif')
  129.  1413  FORMAT(' alt=' '[ FCC Seal ]' '></TD><TD><B><H2>')
  130.  1414  FORMAT('<Font Color="#D81654">COLORIT Color ')
  131.  1415  FORMAT(' Generator</Font> ------ <Font Size=2><A HREF=')
  132.  1416  FORMAT('http://www.fcc.gov/mmb/asd/bickel/fortran.html')
  133.  1417  FORMAT('>A  Fortran CGI</A></Font></H2> Page 2')
  134.  1418  FORMAT(' -- Output</TD></TR></TABLE></Center><P>')
  135.  
  136. c    ************************************************* 
  137. c    Write the pertinent part of the Input QUERY_STRING to output 
  138.  
  139.        Write(6,79)
  140.  79    Format('<Center><H3><Font Color=' '#FF0000' '>Input Color: ')
  141.        Write(6,81) QS(7:7),QS(8:8),QS(9:9),QS(10:10),QS(11:11),QS(12:12)
  142.  81    Format('</Font><B> '      AAAAAA '</B></H3>')
  143.        Write(6,83)
  144.  83    Format('</Center><P>' )
  145.  
  146. c    ********************************************
  147. c    Here we replicate the initial HTML Form data entry fields
  148.  
  149.        Write(6,87)
  150.        Write(6,88)
  151.        Write(6,89)
  152.        Write(6,90)
  153.  
  154.        Write(6,96)
  155.        Write(6,92)
  156.        Write(6,93)
  157.        Write(6,94)
  158.        Write(6,95)
  159.        Write(6,96)
  160.  
  161.  
  162.  87    Format('<Center><Form method=' 'GET' ' action=')
  163.  88    Format('http://www.fcc.gov/fcc-bin/colorit' '>')
  164.  89    Format('Change Color Here:   ')
  165.  90    Format("<Input type='text' name='input' maxlength='6'>")
  166.  92    Format("<Input Type='submit'  value='Get New Color' >")
  167.  93    Format('<Font Color=' '#FFFFFE' '> . . .</Font>')
  168.  94    Format("<Input Type='reset'  value='Clear Form' >")
  169.  95    Format('</Form></Center>')
  170.  96    Format('<BR><BR>')
  171.  
  172. c    ***********************************************
  173. c    Be aware that "numbers" in the query_string really
  174. c    aren't numbers -- they're ASCII characters.  They must 
  175. c    be converted to integer or real numbers before use, 
  176. c    e.g., if(QS(*:*).eq."1") x=1
  177. c    
  178. c    Character entries in the query string can be retrieved
  179. c    by QS(first char. of substring : last char of substring)
  180. c    Both first and last characters will be retrieved.  
  181. c    
  182. c    In the following code, a numerical character is looked for and
  183. c    converted into its decimal counterpart.
  184.  
  185.        Do i=7,12,1
  186.  
  187.        If(QS(i:i).eq."0")  then
  188.        digit(i)=0.0
  189.        Else if(QS(i:i).eq."1")  then
  190.        digit(i)=1
  191.        Else if(QS(i:i).eq."2")  then
  192.        digit(i)=2
  193.        Else if(QS(i:i).eq."3")  then
  194.        digit(i)=3
  195.        Else if(QS(i:i).eq."4")  then
  196.        digit(i)=4
  197.        Else if(QS(i:i).eq."5")  then
  198.        digit(i)=5
  199.        Else if(QS(i:i).eq."6")  then
  200.        digit(i)=6
  201.        Else if(QS(i:i).eq."7")  then
  202.        digit(i)=7
  203.        Else if(QS(i:i).eq."8")  then
  204.        digit(i)=8
  205.        Else if(QS(i:i).eq."9")  then
  206.        digit(i)=9
  207.        Else if((QS(i:i).eq."A").or.(QS(i:i).eq."a")) then
  208.        digit(i)=10
  209.        Else if((QS(i:i).eq."B").or.(QS(i:i).eq."b"))  then
  210.        digit(i)=11
  211.        Else if((QS(i:i).eq."C").or.(QS(i:i).eq."c"))  then
  212.        digit(i)=12
  213.        Else if((QS(i:i).eq."D").or.(QS(i:i).eq."d"))  then
  214.        digit(i)=13
  215.        Else if((QS(i:i).eq."E").or.(QS(i:i).eq."e"))   then
  216.        digit(i)=14
  217.        Else if((QS(i:i).eq."F").or.(QS(i:i).eq."f"))   then
  218.        digit(i)=15
  219.        Else if(QS(i:i).eq."") then
  220.        Go to 162
  221.        Else 
  222.        Write(6,159) QS(i:i)
  223.  159   Format(A ' is not a valid character -- ')
  224.        Write(6,160)
  225.  160   Format('Please reenter six characters,<P>')
  226.        Write(6,161) 
  227.  161   Format('of type 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F<P>') 
  228.           Go to 335
  229.  162   End if
  230.  
  231.        End do
  232.  
  233.        Write(6,167)
  234.        Write(6,168)
  235.        Write(6,169)
  236.  167   Format('<P>')
  237.  168   Format('<Center>')
  238.  169   Format('<Table width=' '95%' 'border=1>')
  239.  
  240. c    Loop through 9 rows, 4 above & 4 below the entered color code
  241.  
  242.  
  243.        Do j=-4,4,1
  244.        Write(6,177)
  245.  177   Format('<TR align=' 'center' '>')
  246.  
  247.        If(j.eq.0) then
  248.        Write(6,181)QS(7:7),QS(8:8),QS(9:9),QS(10:10),QS(11:11),QS(12:12)
  249.  181   Format('<TD colspan=6 bgcolor=' '#'AAAAAA)
  250.        Write(6,183)
  251.  183   Format('align=' 'center' '>.<BR>')
  252.  
  253. c    Create a small label table, inside the data element
  254.  
  255.        Write(6,189)
  256.        Write(6,190) QS(7:7),QS(8:8),QS(9:9),QS(10:10),QS(11:11),QS(12:12)
  257.  
  258.  189   Format('<Table border=0><TR><TD bgcolor=' '#FFFFFF' '>')
  259.  190   Format('Submitted color= 'AAAAAA' </TD></TR></Table>')
  260.  
  261.        Write(6,193)
  262.  193   Format('<BR>*</TD></TR>')
  263.        Go to 320
  264.          else if(j.ne.0) then       
  265.  
  266. c    Create HTML across the row -- 6 data elements
  267.  
  268.        Write(6,200)
  269.  200   Format('<TR align=' 'center' '>')
  270.  
  271.        Do i=7,12,1
  272.  
  273.        Number=digit(i)+j
  274.  
  275.         If(number.eq.0) then
  276.        newcolor="0"
  277.         Else if(number.eq.1) then
  278.        newcolor="1"
  279.         Else if(number.eq.2) then
  280.        newcolor="2"
  281.         Else if(number.eq.3) then
  282.        newcolor="3"
  283.         Else if(number.eq.4) then
  284.        newcolor="4"
  285.         Else if(number.eq.5) then
  286.        newcolor="5"
  287.         Else if(number.eq.6) then
  288.        newcolor="6"
  289.         Else if(number.eq.7) then
  290.        newcolor="7"
  291.         Else if(number.eq.8) then
  292.        newcolor="8"
  293.         Else if(number.eq.9) then
  294.        newcolor="9"
  295.         Else if(number.eq.10) then
  296.        newcolor="A"
  297.         Else if(number.eq.11) then
  298.        newcolor="B"
  299.         Else if(number.eq.12) then
  300.        newcolor="C"
  301.         Else if(number.eq.13) then
  302.        newcolor="D"
  303.         Else if(number.eq.14) then
  304.        newcolor="E"
  305.         Else if(number.eq.15) then
  306.        newcolor="F"
  307.         End if
  308.  
  309.        If((number.lt.0).or.(number.gt.15)) then
  310.        Write(6,243)
  311.  243      Format('<TD bgcolor=')
  312.           Write(6,244)
  313.  244      Format('#FFFFFF' '>No color</TD>')
  314.        Go to 320
  315.        End if
  316.  
  317.        Write(6,243)
  318.  
  319.        If(i.eq.7) then
  320.        write(6,270)newcolor,QS(8:8),QS(9:9),QS(10:10),QS(11:11),QS(12:12)
  321.  
  322.        Else if(i.eq.8) then
  323.        Write(6,270)QS(7:7),newcolor,QS(9:9),QS(10:10),QS(11:11),QS(12:12)
  324.  
  325.        Else if(i.eq.9) then
  326.        Write(6,270)QS(7:7),QS(8:8),newcolor,QS(10:10),QS(11:11),QS(12:12)
  327.  
  328.        Else if(i.eq.10) then
  329.        Write(6,270)QS(7:7),QS(8:8),QS(9:9),newcolor,QS(11:11),QS(12:12)
  330.  
  331.        Else if(i.eq.11) then
  332.        Write(6,270)QS(7:7),QS(8:8),QS(9:9),QS(10:10),newcolor,QS(12:12)
  333.  
  334.        Else if(i.eq.12) then
  335.        Write(6,270)QS(7:7),QS(8:8),QS(9:9),QS(10:10),QS(12:12),newcolor
  336.  
  337.        End if
  338.  270   Format(AAAAAA' align=' 'center' '><BR>')
  339.  
  340.  
  341. c    Create a label table inside the data element
  342.  
  343.        Write(6,276)
  344.  276   Format('<Table border=0><TR align=' 'center' '>')
  345.  
  346.        If(i.eq.7) then
  347.        Write(6,311)
  348.        Write(6,312)newcolor,QS(8:8),QS(9:9),QS(10:10),QS(11:11),QS(12:12)
  349.        Write(6,313)newcolor,QS(8:8),QS(9:9),QS(10:10),QS(11:11),QS(12:12)
  350.  
  351.        Else if(i.eq.8) then
  352.        Write(6,311)
  353.        Write(6,312)QS(7:7),newcolor,QS(9:9),QS(10:10),QS(11:11),QS(12:12)
  354.        Write(6,313)QS(7:7),newcolor,QS(9:9),QS(10:10),QS(11:11),QS(12:12)
  355.  
  356.        Else if(i.eq.9) then
  357.        Write(6,311)
  358.        Write(6,312)QS(7:7),QS(8:8),newcolor,QS(10:10),QS(11:11),QS(12:12)
  359.        Write(6,313)QS(7:7),QS(8:8),newcolor,QS(10:10),QS(11:11),QS(12:12)
  360.  
  361.        Else if(i.eq.10) then
  362.        Write(6,311)
  363.        Write(6,312)QS(7:7),QS(8:8),QS(9:9),newcolor,QS(11:11),QS(12:12)
  364.        Write(6,313)QS(7:7),QS(8:8),QS(9:9),newcolor,QS(11:11),QS(12:12)
  365.  
  366.        Else if(i.eq.11) then
  367.        Write(6,311)
  368.        Write(6,312)QS(7:7),QS(8:8),QS(9:9),QS(10:10),newcolor,QS(12:12)
  369.        Write(6,313)QS(7:7),QS(8:8),QS(9:9),QS(10:10),newcolor,QS(12:12)
  370.  
  371.        Else if(i.eq.12) then
  372.        Write(6,311)
  373.        Write(6,312)QS(7:7),QS(8:8),QS(9:9),QS(10:10),QS(11:11),newcolor
  374.        Write(6,313)QS(7:7),QS(8:8),QS(9:9),QS(10:10),QS(11:11),newcolor
  375.  
  376.        End if
  377.  
  378.        Write(6,314)
  379.  
  380.  311   Format('<TD bgcolor=' '#FFFFFF' '><A HREF=')
  381.  312   Format('http://www.fcc.gov/fcc-bin/colorit?input='AAAAAA'>')
  382.  313   Format(AAAAAA'</A></TD>')
  383.  314   Format('</TR></Table>')
  384.  
  385.        Write(6,318)
  386.  318   Format('<BR>.</TD>')
  387.  
  388.  320   Continue
  389.        End do
  390.  
  391.        Write(6,324)
  392.  324   Format('</TR>')
  393.  
  394.  99    Continue
  395.        End do
  396.  
  397.        End if
  398.        Write(6,330)
  399.  330   Format('</table></center>')
  400.  
  401.        Write(6,331)
  402.        Write(6,332)
  403.        Write(6,333)
  404.  331   Format('<P><Center><Font Size=2>NOTE: Because the colors')
  405.  332   Format(' above are shown as BACKGROUNDS, <BR>they will')
  406.  333   Format('  not show up when this page is printed.</Font><P>') 
  407.  
  408.  335   Continue
  409.  
  410.        Write(6,337)
  411.        Write(6,338)
  412.        Write(6,339)
  413.        Write(6,338)
  414.        Write(6,340)  
  415.  337   Format('This document may be accessed at <A HREF=')
  416.  338   Format('http://www.fcc.gov/mmb/asd/bickel/colorit.html')
  417.  339   Format('>') 
  418.  340   Format('</A><P></Center>')
  419.  
  420.  
  421. c    Now that all of the colors have been shown, set up end-of-page
  422. c    links & gifs
  423.  
  424.        Write(6,400)
  425.        Write(6,401)
  426.        Write(6,402)
  427.        Write(6,403)
  428.        Write(6,404)
  429.  
  430.        Write(6,400)
  431.        Write(6,405)
  432.        Write(6,406)
  433.        Write(6,407)
  434.        Write(6,408)
  435.  
  436.        Write(6,406)
  437.        Write(6,409)
  438.        Write(6,410)
  439.        Write(6,406)
  440.        Write(6,411)
  441.        Write(6,412)
  442.        Write(6,406)
  443.        Write(6,413)
  444.        Write(6,414)
  445.        Write(6,406)
  446.        Write(6,415)
  447.        Write(6,416)      
  448.        Write(6,406)
  449.        Write(6,417)
  450.        Write(6,418)
  451.        Write(6,406)
  452.        Write(6,419)
  453.        Write(6,420)
  454.        Write(6,406)
  455.        Write(6,421)
  456.  
  457.        Write(6,422)
  458.        Write(6,406)
  459.        Write(6,423)
  460.        Write(6,424)
  461.        Write(6,406)
  462.        Write(6,425)
  463.        Write(6,426)
  464.        Write(6,406)
  465.        Write(6,427)
  466.        Write(6,428)
  467.        Write(6,400)
  468.  
  469.  400   Format('<CENTER>')
  470.  401   Format('<IMG SRC=' 'http://www.fcc.gov/mmb/gif/yl_bar.gif')
  471.  402   Format(' alt=' ' Line Across Page ' '>')
  472.  403   Format('</Center>')
  473.  404   Format('<P>')
  474.  405   Format('<B>Jump to:</B><BR>')
  475.  406   Format('<A HREF=')
  476.  407   Format('http://www.fcc.gov/mmb/asd/' '>')
  477.  408   Format('ASD Subject Index</A>,')
  478.  409   Format('http://www.fcc.gov/mmb/asd/welcomeALT.html' '>')
  479.  410   Format('ASD Alphabetical Index</A>,')
  480.  411   Format('http://www.fcc.gov/search/' '>')
  481.  412   Format('FCC Search Engine</A></CENTER><BR><UL><LI>')
  482.  
  483.  413   Format('http://www.fcc.gov/mmb/asd/main/filing.html' '>')
  484.  414   Format('Filing an Application</A><LI>')
  485.  415   Format('http://www.fcc.gov/mmb/asd/main/information.html')
  486.  416   Format('>Application Information</A><LI>')
  487.  417   Format('http://www.fcc.gov/mmb/asd/main/am.html' '>')
  488.  418   Format('AM</A><LI>')
  489.  419   Format('http://www.fcc.gov/mmb/asd/main/fm.html' '>')
  490.  420   Format('FM and FM Translators & Boosters</A><LI>')
  491.  421   Format('http://www.fcc.gov/mmb/asd/main/fact.html' '>')
  492.  422   Format('Fact Sheets</A><LI>')
  493.  423   Format('http://www.fcc.gov/mmb/asd/decdoc/intro.html')
  494.  424   Format('>Decisions</A><LI>')
  495.  425   Format('http://www.fcc.gov/mmb/asd/main/other.html#WITHIN')
  496.  426   Format('>Links Within FCC</A><LI>')
  497.  427   Format('http://www.fcc.gov/mmb/asd/main/other.html#OUTSIDE')
  498.  428   Format('>Links to Outside the FCC</A></UL><P>')
  499.  
  500.        Write(6,406)
  501.        Write(6,429)
  502.        Write(6,430)
  503.        Write(6,431)
  504.        Write(6,432)
  505.        Write(6,433)
  506.        Write(6,434)
  507.      
  508.  429   Format('http://www.fcc.gov/mmb/' '>Mass Media Bureau</A>')
  509.  430   Format(' -- <A HREF=' 'http://www.fcc.gov/' '>Federal ')
  510.  431   Format('  Communications Commission</A></CENTER><P>')
  511.  432   Format('<BR><BR><CENTER><IMG SRC=')
  512.  433   Format('http://www.fcc.gov/fcc-gifs/small_seal.gif')
  513.  434   Format(' alt=' '[ FCC Seal ]' '></CENTER>')
  514.  
  515.  
  516. c    ********************************************
  517. c    Without a closing HTML statement, you may not see ANY output!
  518.      
  519.        Write(6,999)
  520.  999   Format('</Body></HTML>')
  521.        Call Exit
  522.  
  523. c    END OF PROGRAM   
  524.        END
  525.